import request from '@/utils/request'
import { camelCaseObject } from '@/libs/object'

const AUTH_PREFIX_V1 = `/api/v1/rds`

export function getRdsInstanceList(params) {
  return request.get(`${AUTH_PREFIX_V1}/instances`, { params }).then(res => camelCaseObject(res))
}

export function getRdsInstanceListByPage(params) {
  return request.get(`${AUTH_PREFIX_V1}/instances/page`, { params }).then(res => camelCaseObject(res))
}

export function getRdsInstance(instanceId) {
  return request.get(`${AUTH_PREFIX_V1}/instances/${instanceId}`).then(res => camelCaseObject(res))
}

export function createRdsInstance(params) {
  return request.post(`${AUTH_PREFIX_V1}/instances`, params).then(res => camelCaseObject(res))
}

export function updateRdsInstance(instanceId, params) {
  return request.put(`${AUTH_PREFIX_V1}/instances/${instanceId}`, params).then(res => camelCaseObject(res))
}

export function deleteRdsInstance(instanceId) {
  return request.delete(`${AUTH_PREFIX_V1}/instances/${instanceId}`).then(res => camelCaseObject(res))
}
